package qj.app.console.invoker;

import java.util.Map;

import qj.util.ProcessUtil;
import qj.util.ThreadUtil;
import qj.util.funct.P0;
import qj.util.swing.ConsolePane;

public abstract class AbstractInvoker implements Invoker {
	protected Map<String, String> typeConfig;
	protected Map<String, String> config;
	protected P0 onStart;
	protected P0 onStop;
	protected Process process;
	protected ConsolePane ta;

	public void setTextArea(ConsolePane ta) {
		this.ta = ta;
	}
	public void init(Map<String, String> typeConfig,Map<String,String> config) {
		this.typeConfig = typeConfig;
		this.config = config;
	}

	public void onStart(P0 onStart) {
		this.onStart = onStart;
	}
	public void onStop(P0 onStop) {
		this.onStop = onStop;
	}

	public void restart() {
		ProcessUtil.onExit(process, new P0() {public void e() {
			ThreadUtil.sleep(10);
			start();
		}});
		stop();
	}
}
